{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/weike/template/web/call/navbar'}
    <form id="call_group_form" action="" method="post" class="form-horizontal" role="form">
        <div class="panel panel-default" role="tabpanel" style="">
            <div class="panel-heading">打call礼品信息</div>
            <div class="panel-body">
                <input type="hidden" name="call_group_id" value="{$call_group_id}"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>
                <input type="hidden" name="gift_id" value="{$gift_id}"/>
                <div class="form-group" >
                    <label class="col-sm-2 col-xs-12 control-label">打call礼品名称</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <input type="text" class="form-control"  placeholder="请输入打call礼品名称" name="title"  value="{php echo !$gift_id?'':$data['title'];}">
                            <span class="input-group-addon"></span>
                        </div>
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">打call礼品图片</label>
                    <div class="col-sm-8 col-xs-12">
                        {php echo view_form_field_image('content',$content);}
<!--                        <span class="help-block">提示：最多上传3张。</span>-->
                    </div>
                </div>

                <div class="form-group" >
                    <label class="col-sm-2 col-xs-12 control-label">打call数量</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="input-group">
                            <input type="text" class="form-control"  placeholder="" name="num_limit"  value="{php echo empty($data['num_limit'])?0:$data['num_limit'];}">
                            <span class="input-group-addon"></span>
                        </div>
                        <span class="help-block">提示：客户达到收集打call的数量才可获得相应礼品。</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label">是否启用</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <label class="radio-inline">
                            <input name="status" value="1" {if !$gift_id || $data['status']==1} checked="checked"{/if} type="radio">启用
                        </label>
                        <label class="radio-inline">
                            <input name="status" value="0" {if $gift_id && $data['status']==0} checked="checked"{/if} type="radio">禁用
                        </label>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group" id="sub_upload" >
            <div class="col-sm-12">
                <input name="submit" onclick="addOrEditItem()" id="btnConfirm" type="button" value="提交" class="btn btn-primary col-lg-2">
            </div>
        </div>
    </form>
</div>


{$pager}
<script type="text/javascript">
    $(document).ready(
        function (){
            console.log('js代码');
        }
    );
    //新增\修改 提交数据
    function addOrEditItem() {
        let postUrl = "{php echo createWebUrlPlugin('weike.call.addgiftinfo',array('themeid'=>$themeid));}";
        let success_redirect = "{php echo createWebUrlPlugin('weike.call.giftmain',array('themeid'=>$themeid,'call_group_id'=>$call_group_id));}";
        let formData = $("#call_group_form").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                console.log(e)
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.message)
                }else{
                    layer.msg(result.message);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
</script>
